<!DOCTYPE html>
<html>
<head>
    <title>安和寿</title>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">

    <meta name="description" content="安和寿微信预约端">

    <link rel="stylesheet" href="${basePath}/css/weui.min.css">
    <link rel="stylesheet" href="${basePath}/css/jquery-weui.css">
    <link rel="stylesheet" href="${basePath}/css/demos.css">

</head>

<body ontouchstart>

<div class="weui-tab">
    <div class="weui-tab__bd">
        <div id="tab1" class="weui-tab__bd-item <#if tab="1">weui-tab__bd-item--active</#if>">

            <header class='demos-header'>
                <div class="demos-title">
                            <span>
                                <img src="${basePath}/images/logo.jpg" width="30px" style="margin-top: 5px;"/>
                            </span>
                    <span>&nbsp;安和寿</span>
                </div>
            </header>

            <div class="weui-search-bar" id="searchBar">
                <form class="weui-search-bar__form">
                    <div class="weui-search-bar__box">
                        <i class="weui-icon-search"></i>
                        <input type="search" class="weui-search-bar__input" id="searchInput" placeholder="搜索" required="">
                        <a href="javascript:" class="weui-icon-clear" id="searchClear"></a>
                    </div>
                    <label class="weui-search-bar__label" id="searchText" style="transform-origin: 0px 0px 0px; opacity: 1; transform: scale(1, 1);">
                        <i class="weui-icon-search"></i>
                        <span>搜索</span>
                    </label>
                </form>
                <a href="javascript:" class="weui-search-bar__cancel-btn" id="searchCancel">取消</a>
            </div>


            <div class="weui-grids" style="margin-bottom: 53px;">
            <#if depts?? && (depts?size > 0) >
                <#list depts as dept>
                    <a href="#" class="weui-grid js_grid" id="dept${dept.id}">
                        <div class="weui-grid__icon">
                            <img src="${basePath}/departIcon.img?departmentId=${dept.id}" alt="">
                        </div>
                        <p class="weui-grid__label">
                        ${dept.name}
                        </p>
                    </a>
                </#list>
            </#if>
            </div>

        </div>
        <div id="tab2" class="weui-tab__bd-item <#if tab="2" >weui-tab__bd-item--active</#if>">

            <div class="page__bd" style="margin-bottom: 53px;">
                <div class="weui-panel weui-panel_access">
                    <div class="weui-panel__bd" id="doctorList">
                    <#if doctors?? && (doctors?size > 0) >
                        <#list doctors as doctor>
                            <a href="javascript:detailDoctor(${doctor.id?c});" class="weui-media-box weui-media-box_appmsg">
                                <div class="weui-media-box__hd">
                                    <img src="${basePath}/icon.img?doctorId=${doctor.id?c}" alt="" style="width:65px;height:90px;">
                                </div>
                                <div class="weui-media-box__bd">
                                    <h4 class="weui-media-box__title">
                                        <strong>${doctor.name}</strong>
                                    </h4>
                                    <p class="weui-media-box__desc">${doctor.departmentName} ${doctor.titleName}</p>
                                    <p class="weui-media-box__desc"><span class="hospital">${doctor.hospital}</span></p>
                                </div>
                                <div class="weui-cell__ft">
                                    <span class="doctor-label">已关注</span>
                                </div>
                            </a>
                        </#list>
                    <#else>
                        <h1 class="demos-title" style="font-size: 24px;">您尚未关注任何医生</h1>
                    </#if>
                    </div>
                </div>
            </div>

        </div>
        <div id="tab3" class="weui-tab__bd-item <#if tab="3" >weui-tab__bd-item--active</#if>">

            <div class="weui-cells weui-cells_form" style="margin-top:0px;">
                <div class="weui-cell">
                    <div class="weui-cell__hd"><label class="weui-label" style="color: #90969A;">用户名：</label></div>
                    <div class="weui-cell__bd">
                        <input class="weui-input" type="text" id="nickname" name="nickname" placeholder="请输入用户名" value="${customer.name!}">
                    </div>
                </div>
            </div>

            <div class="weui-cells weui-cells_form" style="margin-top:0px;">
                <div class="weui-cell weui-cell_select weui-cell_select-after">
                    <div class="weui-cell__hd">
                        <label for="" class="weui-label" style="color: #90969A;">性别：</label>
                    </div>
                    <div class="weui-cell__bd">
                        <select class="weui-select" name="select2" id="sex">
                            <option value="0" <#if customer.sex??><#if customer.sex==1>selected</#if></#if> >男</option>
                            <option value="1" <#if customer.sex??><#if customer.sex==0>selected</#if></#if> >女</option>
                        </select>
                    </div>
                </div>
            </div>

            <div class="weui-cells" style="margin-top:0px;">
                <div class="weui-cell weui-cell_select weui-cell_select-after">
                    <div class="weui-cell__hd">
                        <label for="" class="weui-label" style="color: #90969A;">职位：</label>
                    </div>
                    <div class="weui-cell__bd">
                        <select class="weui-select" name="select2" id="position">
                            <option value="医生" <#if customer.position??><#if customer.position="医生">selected</#if></#if>>医生</option>
                            <option value="负责人">负责人</option>
                            <option value="其他" <#if customer.position??><#if customer.position="其他">selected</#if></#if>>其他</option>
                        </select>
                    </div>
                </div>
            </div>

            <div class="weui-cells weui-cells_form" style="margin-top:0px;">
                <div class="weui-cell">
                    <div class="weui-cell__hd"><label class="weui-label" style="color: #90969A;">联系电话：</label></div>
                    <div class="weui-cell__bd">
                        <input class="weui-input" type="tel" id="cellphone" name="cellphone" placeholder="请输入联系电话" value="${customer.cellphone!}">
                    </div>
                </div>
            </div>

            <div class="weui-cells weui-cells_form" style="margin-top:0px;">
                <div class="weui-cell weui-cell_switch">
                    <div class="weui-cell__bd" style="color: #90969A;">所属医疗机构：</div>
                </div>
                <div class="weui-cell">
                    <div class="weui-cell__bd">
                        <input class="weui-input" type="text" id="clinic" name="clinic" placeholder="请输入机构名称" value="${customer.clinic!}">
                    </div>
                </div>
                <div class="weui-cell weui-cell_switch">
                    <div class="weui-cell__bd" style="color: #90969A;">地址：</div>
                </div>
                <div class="weui-cell">
                    <div class="weui-cell__bd">
                        <input class="weui-input" type="text" id="address" name="address" placeholder="请输入机构所在地" value="${customer.address!}">
                    </div>
                </div>
                <div class="weui-cell weui-cell_switch">
                    <div class="weui-cell__bd" style="color: #90969A;">简介：</div>
                </div>
                <div class="weui-cell">
                    <div class="weui-cell__bd">
                        <textarea class="weui-textarea" id="introduction" name="introduction" placeholder="请输入机构简介" rows="3">${customer.introduction!}</textarea>
                    </div>
                </div>
            </div>

            <label for="weuiAgree" class="weui-agree">
                <input id="weuiAgree" type="checkbox" class="weui-agree__checkbox">
                        <span class="weui-agree__text" style="color: #90969A;">
                            阅读并同意<a href="javascript:void(0);">《相关条款》</a>
                        </span>
            </label>

            <div class="weui-btn-area" style="margin-bottom: 53px;">
                <a class="weui-btn weui-btn_primary" href="javascript:submintInfo();" id="showTooltips">确定</a>
            </div>

        </div>
        <div id="tab4" class="weui-tab__bd-item <#if tab="4" >weui-tab__bd-item--active</#if>">


            <div class="page__bd" style="margin-bottom: 53px;">
                <div class="weui-panel weui-panel_access" id="orderList">
                    <div class="weui-panel__bd">
                    <#if orders?? && (orders?size > 0) >
                        <#list orders as order>
                            <#if order.type=0>
                                <a href="javascript:detailOrder(${order.id?c});" class="weui-media-box weui-media-box_appmsg">
                                    <div class="weui-media-box__hd">
                                        <img src="${basePath}/icon.img?doctorId=${order.doctor.id?c}" alt="" style="width:65px;height:90px;">
                                    </div>
                                    <div class="weui-media-box__bd">
                                        <h4 class="weui-media-box__title">
                                            <strong>${order.doctor.name}</strong>
                                        </h4>
                                        <p class="weui-media-box__desc">${order.doctor.departmentName} ${order.doctor.titleName}</p>
                                        <p class="weui-media-box__desc"><span class="hospital">${order.doctor.hospital}</span></p>
                                    </div>
                                    <div class="weui-cell__ft">
                                        <span class="product">${order.productType}</span>
                                    </div>
                                    <div class="weui-cell__ft2">
                                        <#if order.status=0>
                                            <span class="status-process">已预约</span>
                                        </#if>
                                        <#if order.status=1>
                                            <span class="status-process">已付款</span>
                                        </#if>
                                        <#if order.status=2>
                                            <span class="status-success">已完成</span>
                                        </#if>
                                    </div>
                                </a>
                            <#else>
                                <a href="javascript:detailOrder(${order.id?c});" class="weui-media-box weui-media-box_appmsg">
                                    <div class="weui-media-box__hd">
                                        <h1>特约</h1>
                                    </div>
                                    <div class="weui-media-box__bd">
                                        <h4 class="weui-media-box__title">
                                            <strong>${order.memoObj.name}</strong>
                                        </h4>
                                        <p class="weui-media-box__desc">${order.memoObj.department!}</p>
                                        <p class="weui-media-box__desc"><span class="hospital">${order.memoObj.hospital!}</span></p>
                                    </div>
                                    <div class="weui-cell__ft2">
                                        <#if order.status=0>
                                            <span class="status-process">已预约</span>
                                        </#if>
                                        <#if order.status=1>
                                            <span class="status-process">已付款</span>
                                        </#if>
                                        <#if order.status=2>
                                            <span class="status-success">已完成</span>
                                        </#if>
                                    </div>
                                </a>
                            </#if>
                        </#list>
                    <#else>
                        <h1 class="demos-title" style="font-size: 24px;">没有数据</h1>
                    </#if>
                    </div>
                </div>
            </div>

        </div>
    </div>

    <div class="weui-tabbar">
        <a href="#tab1" class="weui-tabbar__item <#if tab="1" >weui-bar__item--on</#if>">
            <div class="weui-tabbar__icon">
                <img src="${basePath}/images/icon_nav_button.png" alt="">
            </div>
            <p class="weui-tabbar__label">找医生</p>
        </a>
        <a href="#tab2" class="notice weui-tabbar__item <#if tab="2" >weui-bar__item--on</#if>">
            <div class="weui-tabbar__icon">
                <img src="${basePath}/images/icon_nav_msg.png" alt="">
            </div>
            <p class="weui-tabbar__label">我的医生</p>
        </a>
        <a href="#tab3" class="info weui-tabbar__item <#if tab="3" >weui-bar__item--on</#if>">
            <div class="weui-tabbar__icon">
                <img src="${basePath}/images/icon_nav_cell.png" alt="">
            </div>
            <p class="weui-tabbar__label">我的信息</p>
        </a>
        <a href="#tab4" class="order weui-tabbar__item <#if tab="4" >weui-bar__item--on</#if>">
            <div class="weui-tabbar__icon">
                <img src="${basePath}/images/icon_nav_article.png" alt="">
            </div>
            <p class="weui-tabbar__label">我的预约</p>
        </a>
    </div>
</div>


<script src="${basePath}/js/jquery-2.1.4.js"></script>
<script src="${basePath}/js/fastclick.js"></script>
<script src="${basePath}/js/jquery-weui.js"></script>
<script>
    $(function () {
        FastClick.attach(document.body);

        $(".weui-grids a").on("click", function () {
            var a=$(this)[0];
            var id=a.id;
            var id=id.replace("dept","");
            location.href = "${basePath}/list.htm?dept="+id;
        });
        $("#searchInput").focus(function () {
            location.href = "${basePath}/list.htm?type=0";
        });

        $(document).on("click", ".notice", function() {
            noticeClick();
        });
        $(document).on("click", ".info", function() {
            infoClick();
        });
        $(document).on("click", ".order", function() {
            orderClick();
        });

    });
    function noticeClick(){
        $.ajax({
            type: "get",
            async: false,
            url: '${basePath}/getNotices.json',
            data: {},
            success: function (data) {
                var text="";
                if(data&&data.length>0){
                    for (var i = 0; i < data.length; i++) {
                        var doctor = data[i];
                        text += '<a href="javascript:detailDoctor('+doctor.id+');" class="weui-media-box weui-media-box_appmsg">'+
                                '<div class="weui-media-box__hd">'+
                                '<img src="${basePath}/icon.img?doctorId='+ doctor.id+'" alt="" style="width:65px;height:90px;">'+
                                '</div>'+
                                '<div class="weui-media-box__bd">'+
                                '<h4 class="weui-media-box__title">'+
                                '<strong>'+doctor.name+'</strong>'+
                                '</h4>'+
                                '<p class="weui-media-box__desc">'+doctor.departmentName+' '+doctor.titleName+'</p>'+
                                '<p class="weui-media-box__desc"><span class="hospital">'+doctor.hospital+'</span></p>'+
                                '</div>'+
                                '<div class="weui-cell__ft">'+
                                '<span class="doctor-label">已关注</span>'+
                                '</div>'+
                                '</a>';
                    }
                }else{
                    text='<h1 class="demos-title" style="font-size: 24px;">您尚未关注任何医生</h1>';
                }
                $("#doctorList").html(text);
            }
        });
    }
    function infoClick(){
        $.ajax({
            type: "get",
            async: false,
            url: '${basePath}/getCustomer.json',
            data: {},
            success: function (data) {
                $("#nickname").val(data.name);
                $("#sex").val(data.sex);
                $("#position").val(data.position);
                $("#cellphone").val(data.cellphone);
                $("#clinic").val(data.clinic);
                $("#address").val(data.address);
                $("#introduction").val(data.introduction);
            }
        });
    }
    function orderClick(){
        $.ajax({
            type: "get",
            async: false,
            url: '${basePath}/getOrders.json',
            data: {},
            success: function (data) {
                var text="";
                if(data&&data.length>0){
                    for (var i = 0; i < data.length; i++) {
                        var order = data[i];
                        if(order.type==0){
                            text += '<a href="javascript:detailOrder('+order.id+');" class="weui-media-box weui-media-box_appmsg">'+
                                    '<div class="weui-media-box__hd">'+
                                    '<img src="${basePath}/icon.img?doctorId='+order.doctor.id+'" alt="" style="width:65px;height:90px;">'+
                                    '</div>'+
                                    '<div class="weui-media-box__bd">'+
                                    '<h4 class="weui-media-box__title">'+
                                    '<strong>'+order.doctor.name+'</strong>'+
                                    '</h4>'+
                                    '<p class="weui-media-box__desc">'+order.doctor.departmentName+' '+order.doctor.titleName+'</p>'+
                                    '<p class="weui-media-box__desc"><span class="hospital">'+order.doctor.hospital+'</span></p>'+
                                    '</div>'+
                                    '<div class="weui-cell__ft">'+
                                    '<span class="product">'+order.productType+'</span>'+
                                    '</div>'+
                                    '<div class="weui-cell__ft2">';
                        }else{
                            text += '<a href="javascript:detailOrder('+order.id+');" class="weui-media-box weui-media-box_appmsg">'+
                                    '<div class="weui-media-box__hd">'+
                                    '<h1 class="demos-title">特约</h1>'+
                                    '</div>'+
                                    '<div class="weui-media-box__bd">'+
                                    '<h4 class="weui-media-box__title">'+
                                    '<strong>'+order.memoObj.name+'</strong>'+
                                    '</h4>'+
                                    '<p class="weui-media-box__desc">'+order.memoObj.department+'</p>'+
                                    '<p class="weui-media-box__desc"><span class="hospital">'+order.memoObj.hospital+'</span></p>'+
                                    '</div>'+
                                    '<div class="weui-cell__ft2">';
                        }
                        if(order.status==0){
                            text+='<span class="status-process">已预约</span>';
                        }
                        if(order.status==-1){
                            text+='<span class="status-cancel">已取消</span>';
                        }
                        if(order.status==1){
                            text+='<span class="status-process">已付预付款</span>';
                        }
                        if(order.status==2){
                            text+='<span class="status-process">已付全款</span>';
                        }
                        if(order.status==3){
                            text+='<span class="status-success">已完成</span>';
                        }
                        text += '</div>'+'</a>';
                    }
                }else{
                    text='<h1 class="demos-title" style="font-size: 24px;">您尚未预约</h1>';
                }
                $("#orderList").html(text);
            }
        });
    }

    function detailDoctor(id){
        location.href = "${basePath}/detail.htm?doctorId="+id;
    }
    function detailOrder(id){
        location.href = "${basePath}/detailOrder.htm?orderId="+id;
    }
    function submintInfo(){
        var name=$("#nickname").val();
        if(name.length==0){
            $.toast("用户名不能为空", "forbidden");
            return false;
        }
        var sex=$("#sex").val();
        var position=$("#position").val();
        var cellphone=$("#cellphone").val();
        if(cellphone.length==0){
            $.toast("联系电话不能为空", "forbidden");
            return false;
        }
        var clinic=$("#clinic").val();
        if(clinic.length==0){
            $.toast("机构名称不能为空", "forbidden");
            return false;
        }
        var address=$("#address").val();
        if(address.length==0){
            $.toast("机构所在地不能为空", "forbidden");
            return false;
        }
        var introduction=$("#introduction").val();
        if (!$("#weuiAgree").get(0).checked) {
            $.toast("尚未同意用户条款", "forbidden");
            return false;
        }

        var data={
            name: name,
            sex: sex,
            cellphone: cellphone,
            clinic: clinic,
            position: position,
            address: address,
            introduction: introduction
        }
        $.ajax({
            type: "post",
            async: false,
            url: '${basePath}/updateCustomer.json',
            contentType: "application/x-www-form-urlencoded; charset=utf-8",
            data: data,
            success: function (data) {
                $.toast("用户信息已保存!");
            }
        });
    }
</script>

</body>
</html>
